package com.geek.javase.ch12.work;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/*
 *@author wangpeng
 *2025/10/23 18:29
 *@description TODO
 */
//文件拷贝
//2.FileXxx 和  BufferedXxx 两者哪一个效率高
//Buffered...高效流 、 File...节点流      选择高效流
//BufferedInputStream &  BufferedOutputStream

public class Demo4 {
        public static void main(String[] args) {
            try(FileInputStream fis = new FileInputStream("fileCopy.txt");) {
                byte[] b = new byte[1024];
                int len=0;
                while((len= fis.read(b))!=-1){
                    System.out.println(new String(b,0,len));
                }
            }  catch (IOException e) {
                throw new RuntimeException(e);
            }
            try(
                    FileOutputStream fis = new FileOutputStream("fileCopy.txt", true);
            ) {
                fis.write('\n');
                fis.write('h');
                fis.write(new byte[]{'a','b','c'});

            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
}




